home *** CD-ROM | disk | FTP | other *** search
- #! /bin/csh -f
- #
- # $Id: Setrcsstate,v 1.3 93/08/20 12:40:55 carlson Exp $
- #
- # Setrcsstate Sets a name for a revision of every RCS file.
- #
- # Synopsis:
- # Setrcsstate [-l] <name>
- # Setrcsstate [-m] <name>:<rev>
- #
- # Description:
- # This script sets the state for a revison of an RCS file.
- #
- # In the first form, the state of the last branch is set to the
- # name given.
- #
- # In the second form, the specified revision is given the
- # state.
- #
- # Parameters:
- # -m Set state only if revision exists.
- # -l Set the last state minus the last component.
- #
- # Revision History:
- # $Log: Setrcsstate,v $
- # Revision 1.3 93/08/20 12:40:55 carlson
- # Fix some comments.
- # If a symbolic revision doesn't exist, see if it is somewhere else in
- # the log file.
- #
- # Revision 1.3 1993/02/14 22:28:33 chris
- # Fixed some of the comments.
- # If a symbolic revision doesn't exist, see if it is somewhere else in
- # the log file.
- #
- # Revision 1.2 92/10/22 11:33:09 chris
- # Check options only if there are parameters.
- #
- # Revision 1.1 92/08/21 16:32:06 carlson
- # Initial revision
- #
- #---------------------------------------------------------------------------
-
- set name = ""
- set last = 0
- set override = 0
- set modify = 0
-
- if ( $#argv >= 1 ) then
- set argv = `getopt lm $*`
- while ( "$1" != "--" )
- switch ( $1 )
- case "-l":
- set last = 1
- shift
- breaksw
-
- case "-m":
- set modify = 1
- shift
- breaksw
- endsw
- end
- shift
- endif
-
- if ( "$1" == "" ) then
- echo "Usage: Setrcsstate <name>"
- echo " Setrcsstate <name>:<rev> [-m]"
- echo " -m = Set state only if revision exists."
- exit
- endif
-
- set name = $1
-
- #----
- # rev = revision portion of name provided (everything after :)
- # name = name portion (everything before :)
- # Revc = revision preceded by colon
- #
- set rev = `echo $name | awk -F: '{ print $2 }'`
- set name = `echo $name | awk -F: '{ print $1 }'`
-
- if ( "$rev" != "" ) then
- set last = 0
- set Revc = :$rev
- else
- set modify = 0
- endif
-
- #----
- # Loop through each RCS file found. If there is an RCS directory,
- # loop through the files ending in ",v" in it. Otherwise, loop
- # through files in the current directory ending in ",v".
- #
- set rcsdir = ""
- if ( -d RCS ) set rcsdir = "RCS/"
- foreach rcsfile ( `ls ${rcsdir}*,v` )
- set file = `basename $rcsfile ,v`
-
- #----
- # If we are supposed to set the last revision, get the last
- # revision and remove the last component.
- #
- # If we are only to set the symbolic name if the revision exists,
- # check if the revision exists and skip if not there.
- #
- if ( $last ) then
- set rev = `rlog $file | grep "^head:" | awk '{print $NF}'`
- set Rev = `echo $rev | awk -F. '{for(i=1;i<NF-1;i++)printf "%s.",$i;print $i}'`
- set Revc = :$Rev
- else if ( $modify ) then
- set x = `rlog $file | grep "^revision $rev"`
- if ( "$x" == "" ) then
- set x = `rlog $file | grep "^symbolic.*$rev"`
- if ( "$x" == "" ) continue
- endif
- endif
-
- rcs -s${name}${Revc} $file
- end
-
- ### Local Variables:
- ### auto-fill-hook: nil
- ### End:
-